//
//  PersonalViewController.m
//  51易借
//
//  Created by 张睿 on 2017/8/31.
//  Copyright © 2017年 张睿. All rights reserved.
//

#import "PersonalViewController.h"
#import "MemberInfoModel.h"
#import "MemberInfoTypePageModel.h"
#import "UIImage+Wechat.h"

@interface PersonalViewController ()<UITextFieldDelegate,STPickerAreaDelegate>
@property (strong, nonatomic) ZYKeyboardUtil *keyboardUtil;
@property (nonatomic,strong)MemberInfoTypePageModel * typePageModel;
@property (nonatomic, weak)UIView * topView;
@property (nonatomic, weak)UILabel * topLabel;
@property (nonatomic, weak)UIView * inputView;
@property (nonatomic, strong)UILabel * IDCardPictureLabel;
@property (nonatomic, strong)UIButton * frontImageButton;
@property (nonatomic, strong)UIButton * contraryImageButton;
@property (nonatomic, strong)UIView * oneLineView;
@property (nonatomic, strong)UILabel * verifyLabel;
@property (nonatomic, strong)UIButton * verifyImageButton;
@property (nonatomic, strong)UIView * twoLineView;
@property (nonatomic, strong)UILabel * nameLabel;
@property (nonatomic, strong)UITextField * nameTextField;
@property (nonatomic, strong)UIView * threeLineView;
@property (nonatomic, strong)UILabel * IDNumberLabel;
@property (nonatomic, strong)UITextField * IDNumberTextField;
@property (nonatomic, strong)UIView * fourLineView;
@property (nonatomic, strong)UILabel * workTypeLabel;
@property (nonatomic, strong)UIButton * workTypeButton;
@property (nonatomic, strong)UIImageView * oneRightImageView;
@property (nonatomic, strong)UIView * fiveLineView;
@property (nonatomic, strong)UILabel * educationLabel;
@property (nonatomic, strong)UIButton * educationButton;
@property (nonatomic, strong)UIImageView * twoRightImageView;
@property (nonatomic, strong)UIView * sixLineView;
@property (nonatomic, strong)UILabel * liveLocalLabel;
@property (nonatomic, strong)UIButton * liveLocalButton;
@property (nonatomic, strong)UIImageView * threeRightImageView;
@property (nonatomic,strong)UITextField * workTypeField;
@property (nonatomic,strong)UITextField * educationField;
@property (nonatomic,strong)UITextField *liveLocalField;
@property (nonatomic,strong)UITextField * liveTimeField;
@property (nonatomic,strong)UITextField * marrayField;


@property (nonatomic, strong)UIView * sevenLineView;
@property (nonatomic, strong)UITextField * liveLocalTextField;
@property (nonatomic, strong)UIView * eightLineView;
@property (nonatomic, strong)UILabel * liveTimeLabel;
@property (nonatomic, strong)UIButton * liveTimeButton;
@property (nonatomic, strong)UIImageView * fourRightImageView;
@property (nonatomic, strong)UIView * nineLineView;
@property (nonatomic, strong)UILabel * marrayLabel;
@property (nonatomic, strong)UIButton * marrayButton;
@property (nonatomic, strong)UIImageView * fiveRightImageView;
@property (nonatomic, strong)UIView * tenLineView;
@property (nonatomic, weak)UIButton * sureButton;
@property (nonatomic, strong)MemberInfoModel * pageModel;
@property (nonatomic, strong)ParaModel * para;


@property (nonatomic, copy)NSString * code;

@end

@implementation PersonalViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = BACK_COLOR;
    
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(check) name:@"check" object:nil];
    
    [self setupNavBar];
    [self setupUI];
    [self configKeyBoardRespond];
    [self getPageModel];
    
}


- (void)setupNavBar{
    
    self.title = @"个人信息";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"箭头"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToLastView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}

-(void)dealloc
{
    self.nameTextField.delegate = nil;
    self.IDNumberTextField.delegate = nil;
    self.liveLocalTextField.delegate = nil;
}

- (void)configKeyBoardRespond {
    self.nameTextField.delegate = self;
    self.IDNumberTextField.delegate = self;
    self.liveLocalTextField.delegate = self;
    self.keyboardUtil = [[ZYKeyboardUtil alloc] initWithKeyboardTopMargin:MARGIN_KEYBOARD];
    __weak PersonalViewController *weakSelf = self;
#pragma explain - 全自动键盘弹出/收起处理 (需调用keyboardUtil 的 adaptiveViewHandleWithController:adaptiveView:)
#pragma explain - use animateWhenKeyboardAppearBlock, animateWhenKeyboardAppearAutomaticAnimBlock will be invalid.
    [_keyboardUtil setAnimateWhenKeyboardAppearAutomaticAnimBlock:^(ZYKeyboardUtil *keyboardUtil) {
        [keyboardUtil adaptiveViewHandleWithController:weakSelf adaptiveView:weakSelf.nameTextField, weakSelf.IDNumberTextField, weakSelf.liveLocalTextField, nil];
    }];

#pragma explain - 获取键盘信息
    [_keyboardUtil setPrintKeyboardInfoBlock:^(ZYKeyboardUtil *keyboardUtil, KeyboardInfo *keyboardInfo) {
//        NSLog(@"\n\n拿到键盘信息 和 ZYKeyboardUtil对象");
    }];
}

- (void)setupUI{
    
    UIView * topView = [UIView new];
    
    topView.backgroundColor = TOTAL_COLOR;
    
    self.topView = topView;
    
    [self.view addSubview:self.topView];
    
    
    UILabel * topLabel = [UILabel new];
    
    topLabel.textColor = ColorWithRGB(0x7f7f7f);
    topLabel.font = [UIFont systemFontOfSize:13.5 * SCREENH6];
    topLabel.text = @"身份认证信息保存后不可修改，请务必保证正确！";
    
    self.topLabel = topLabel;
    
    [self.view addSubview:self.topLabel];
    
    
    UIView * inputView = [UIView new];
    
    inputView.backgroundColor = [UIColor whiteColor];
    inputView.layer.borderColor = [ColorWithRGB(0xe6e6e6) CGColor];
    inputView.layer.borderWidth = 0.5 * SCREENH6;
    
    self.inputView = inputView;
    
    [self.view addSubview:self.inputView];
    
    self.IDCardPictureLabel = [self setupLabelWith:@"身份证照片"];
    
    [self.inputView addSubview:self.IDCardPictureLabel];
    
    self.frontImageButton = [self setupButtonUIImageView];
    self.frontImageButton.tag = 1;
    [self.inputView addSubview:self.frontImageButton];
    [self.frontImageButton addTarget:self action:@selector(chooseImage:) forControlEvents:UIControlEventTouchUpInside];
    self.contraryImageButton = [self setupButtonUIImageView];
    self.contraryImageButton.tag = 2;
    [self.contraryImageButton addTarget:self action:@selector(chooseImage:) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel * frontLabel = [UILabel new];
    
    frontLabel.text = @"正面";
    frontLabel.textColor = BACK_COLOR;
    frontLabel.font = [UIFont systemFontOfSize:14 * SCREENH6];
    
    [self.frontImageButton addSubview:frontLabel];
    
    [frontLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.frontImageButton);
        make.bottom.mas_equalTo(self.frontImageButton).offset(-2 * SCREENH6);
    }];
    
    UILabel * contraryLabel = [UILabel new];
    
    contraryLabel.text = @"反面";
    contraryLabel.textColor = BACK_COLOR;
    contraryLabel.font = [UIFont systemFontOfSize:14 * SCREENH6];
    
    [self.contraryImageButton addSubview:contraryLabel];
    
    [contraryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.contraryImageButton);
        make.bottom.mas_equalTo(self.contraryImageButton).offset(-2 * SCREENH6);
    }];
    

    [self.inputView addSubview:self.contraryImageButton];
    
    self.oneLineView = [self setupLineView];
    
    [self.inputView addSubview:self.oneLineView];
    
    self.verifyLabel = [self setupLabelWith:@"人脸识别"];
    
    [self.inputView addSubview:self.verifyLabel];
    
    self.verifyImageButton = [self setupButtonUIImageView];
    
    [self.inputView addSubview:self.verifyImageButton];
    [self.verifyImageButton addTarget:self action:@selector(verifyTask:) forControlEvents:UIControlEventTouchUpInside];

    self.twoLineView = [self setupLineView];
    
    [self.inputView addSubview:self.twoLineView];
    
    self.nameLabel = [self setupLabelWith:@"姓名"];
    
    [self.inputView addSubview:self.nameLabel];
    
    self.nameTextField  = [self setupTextField:@"请输入您的真实姓名"];
//    self.nameTextField.userInteractionEnabled = NO;
    
    [self.inputView addSubview:self.nameTextField];
    
    self.threeLineView = [self setupLineView];
    
    [self.inputView addSubview:self.threeLineView];
    
    self.IDNumberLabel = [self setupLabelWith:@"身份证号码"];
    
    [self.inputView addSubview:self.IDNumberLabel];
    
    self.IDNumberTextField = [self setupTextField:@"请输入18位身份证号码"];
//    self.IDNumberTextField.userInteractionEnabled = NO;
    [self.inputView addSubview:self.IDNumberTextField];
    
//    if (self.currentStep > 1) {
//        
//        self.code = @"0";
//        self.frontImageButton.userInteractionEnabled = NO;
//        self.contraryImageButton.userInteractionEnabled = NO;
//        self.nameTextField.userInteractionEnabled = NO;
//        self.IDNumberTextField.userInteractionEnabled = NO;
//        
//        self.verifyImageButton.userInteractionEnabled = NO;
//    }else{
//        self.code = @"1";
//        self.frontImageButton.userInteractionEnabled = YES;
//        self.contraryImageButton.userInteractionEnabled = YES;
//        self.nameTextField.userInteractionEnabled = YES;
//        self.IDNumberTextField.userInteractionEnabled = YES;
//        self.verifyImageButton.userInteractionEnabled = YES;
//    }
    
    self.fourLineView = [self setupLineView];
    
    [self.inputView addSubview:self.fourLineView];
    
    self.workTypeLabel = [self setupLabelWith:@"工作类型"];
    
    [self.inputView addSubview:self.workTypeLabel];
    
    
    self.workTypeField = [self setUpTextfieldWithString:@"请选择"];
    self.workTypeField.userInteractionEnabled = NO;
    [self.inputView addSubview:self.workTypeField];

    
    
    self.workTypeButton = [self setupTitleButtonWith:@"请选择"];
    self.workTypeButton.tag = 0;
    [self.inputView addSubview:self.workTypeButton];
    
    self.oneRightImageView = [self setupRightImage];
    
    [self.inputView addSubview:self.oneRightImageView];
    
    self.fiveLineView = [self setupLineView];
    
    [self.inputView addSubview:self.fiveLineView];
    
    self.educationLabel = [self setupLabelWith:@"学历"];
    
    [self.inputView addSubview:self.educationLabel];
    
    
    
    self.educationField = [self setUpTextfieldWithString:@"请选择"];
    self.educationField.userInteractionEnabled = NO;
    [self.inputView addSubview:self.educationField];
    

    self.educationButton = [self setupTitleButtonWith:@"请选择"];
    self.educationButton.tag = 1;

    [self.inputView addSubview:self.educationButton];
    
    self.twoRightImageView = [self setupRightImage];
    
    [self.inputView addSubview:self.twoRightImageView];
    
    self.sixLineView = [self setupLineView];
    
    [self.inputView addSubview:self.sixLineView];
    
    self.liveLocalLabel = [self setupLabelWith:@"现居住地"];
    
    [self.inputView addSubview:self.liveLocalLabel];
    
    self.threeRightImageView = [self setupRightImage];
    
    [self.inputView addSubview:self.threeRightImageView];
    self.liveLocalField = [self setUpTextfieldWithString:@"选择地区"];
    self.liveLocalField.userInteractionEnabled = NO;
    [self.inputView addSubview:self.liveLocalField];
    self.liveLocalButton = [self setupTitleButtonWith:@"选择地区"];
    self.liveLocalButton.tag = 2;
    [self.inputView addSubview:self.liveLocalButton];
    
    
    
  

    
    
    self.sevenLineView = [self setupLineView];
    
    [self.inputView addSubview:self.sevenLineView];
    
    self.liveLocalTextField = [self setupTextField:@"街道和门牌号"];
//    self.liveLocalTextField.userInteractionEnabled = NO;
    [self.inputView addSubview:self.liveLocalTextField];
    
    self.eightLineView = [self setupLineView];
    
    [self.inputView addSubview:self.eightLineView];
    
    self.liveTimeLabel = [self setupLabelWith:@"居住时长"];
    
    [self.inputView addSubview:self.liveTimeLabel];
    
    
    
    self.liveTimeField = [self setUpTextfieldWithString:@"请选择"];
    self.liveTimeField.userInteractionEnabled = NO;
    [self.inputView addSubview:self.liveTimeField];
    

    
    
    self.liveTimeButton = [self setupTitleButtonWith:@"请选择"];
    self.liveTimeButton.tag = 3;
    [self.inputView addSubview:self.liveTimeButton];
    
    self.fourRightImageView = [self setupRightImage];
    
    [self.inputView addSubview:self.fourRightImageView];
    
    self.nineLineView = [self setupLineView];
    
    [self.inputView addSubview:self.nineLineView];
    
    self.marrayLabel = [self setupLabelWith:@"结婚状况"];
    
    [self.inputView addSubview:self.marrayLabel];
    
    
    
    self.marrayField = [self setUpTextfieldWithString:@"请选择"];
    self.marrayField.userInteractionEnabled = NO;
    [self.inputView addSubview:self.marrayField];

    
    
    self.marrayButton = [self setupTitleButtonWith:@"请选择"];
    self.marrayButton.tag = 4;
    [self.inputView addSubview:self.marrayButton];
    
    self.fiveRightImageView = [self setupRightImage];
    
    [self.inputView addSubview:self.fiveRightImageView];
 
    
    UIButton * sureButton = [UIButton new];
    //300 * 42
//    [sureButton setTitle:@"保存" forState:UIControlStateNormal];
//    [sureButton setBackgroundImage:[UIImage imageNamed:@"登录"] forState:UIControlStateNormal];
    
    
    if (self.currentStep > 1) {
        
//        self.code = @"0";
//        self.frontImageButton.userInteractionEnabled = NO;
//        self.contraryImageButton.userInteractionEnabled = NO;
//        self.nameTextField.userInteractionEnabled = NO;
//        self.IDNumberTextField.userInteractionEnabled = NO;
//        
//        self.verifyImageButton.userInteractionEnabled = NO;
        
        [sureButton setTitle:@"保存" forState:UIControlStateNormal];
        [sureButton setBackgroundImage:[UIImage imageNamed:@"登录"] forState:UIControlStateNormal];
        [sureButton setEnabled: YES];
    }else{
        
//        self.code = @"1";
//        self.frontImageButton.userInteractionEnabled = YES;
//        self.contraryImageButton.userInteractionEnabled = YES;
//        self.nameTextField.userInteractionEnabled = YES;
//        self.IDNumberTextField.userInteractionEnabled = YES;
//        self.verifyImageButton.userInteractionEnabled = YES;
        
        [sureButton setBackgroundImage:nil forState:UIControlStateNormal];
        [sureButton setImage:[UIImage imageNamed:@"保存"] forState:UIControlStateNormal];
        [sureButton setEnabled: NO];
    }
    
    [sureButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [sureButton addTarget:self action:@selector(didSaveButton) forControlEvents:UIControlEventTouchUpInside];
    sureButton.titleLabel.font = [UIFont systemFontOfSize:14 * SCREENH6];
    sureButton.hidden = NO;
    
    
    self.sureButton = sureButton;
    
    [self.view addSubview:self.sureButton];
    
    
}



-(void)chooseImage:(UIButton*)button
{
    
    if (button.tag == 2) {
        if (self.nameTextField.text.length == 0){
            [self showHint:@"请先上传身份证正面照片。"];
            return;
        }
    }
    
    [BDImagePicker showImagePickerFromViewController:self allowsEditing:YES finishAction:^(UIImage *image) {
        if (image) {
            if(button.tag == 1)
            {
                
                UIImage *thumbImage = [image wcSessionCompress];
                
                [self getMemberName:thumbImage];
            }else
            {
//                if (self.nameTextField.text.length > 0) {
                
                    UIImage *thumbImage = [image wcSessionCompress];
                    
                    [self upLoadImage:thumbImage complete:^(NSString *imageUrl) {
                        [button setImage:image forState:UIControlStateNormal];
                        self.para.idBackPic = imageUrl;
                    }];
//                }else{
//                    
//                    [self showHint:@"请先上传身份证正面照片。"];
//                }
                

            }
        }

    }];
}










-(void)verifyTask:(UIButton*)button
{
    
    if (self.nameTextField.text.length > 0 && self.para.idBackPic.length > 0) {
      
        [BDImagePicker showImagePickerFromViewController:self front:YES allowsEditing:NO finishAction:^(UIImage *image) {
            if (image) {
                
                UIImage *thumbImage = [image wcSessionCompress];
                
                [self verifyMember:thumbImage];
            }
            
        }];
    }else{
        
        [self showHint:@"身份证验证通过后才可上传人脸照片。"];
    }
    
    
}


-(UITextField*)setUpTextfieldWithString:(NSString*)text
{
    UITextField * textField = [UITextField new];
    textField.borderStyle = UITextBorderStyleNone;
    textField.backgroundColor = [UIColor clearColor];
    textField.layer.borderColor = [[UIColor clearColor] CGColor];
    textField.textAlignment = NSTextAlignmentRight;
    //设置光标颜色
    textField.tintColor = ColorWithRGB(0xcecece);
    //修改占位符文字颜色
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = ColorWithRGB(0xcecece);
//    attrs[NSFontAttributeName] = [UIFont fontWithName:@"PingFangSC-Regular" size:12 * SCREENH6];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12 * SCREENH6];
    //修改占位符文字颜色
    textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:text attributes:attrs];
    textField.textColor = ColorWithRGB(0x303c41);
    textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 22 * SCREENH6, 0)];
    //设置显示模式为永远显示(默认不显示)
    textField.leftViewMode = UITextFieldViewModeAlways;
//    textField.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13 * SCREENH6];
    textField.font = [UIFont systemFontOfSize:12 * SCREENH6];
    return textField;
}


- (void)viewDidLayoutSubviews{
    
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.trailing.mas_equalTo(self.view);
        make.height.mas_equalTo(64);
    }];
    
    [self.topLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(12 * SCREENH6);
        make.top.mas_equalTo(self.topView.mas_bottom).offset(6 * SCREENH6);
    }];
    
    [self.inputView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.view).offset(6 * SCREENH6);
        make.trailing.mas_equalTo(self.view).offset(-6 * SCREENH6);
        make.top.mas_equalTo(self.topLabel.mas_bottom).offset(6 * SCREENH6);
        make.height.mas_equalTo(500 * SCREENH6);
    }];
    
    [self.IDCardPictureLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.inputView).offset(10 * SCREENH6);
        make.top.mas_equalTo(self.inputView).offset(25 * SCREENH6);
    }];
    
    [self.frontImageButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(50 * SCREENH6);
        make.width.mas_equalTo(50 * SCREENH6);

        make.centerY.mas_equalTo(self.IDCardPictureLabel);
        make.trailing.mas_equalTo(self.inputView).offset(-70 * SCREENH6);
    }];
    
    [self.contraryImageButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(50 * SCREENH6);
        make.width.mas_equalTo(50 * SCREENH6);
        
        make.centerY.mas_equalTo(self.IDCardPictureLabel);
        make.trailing.mas_equalTo(self.inputView).offset(-8 * SCREENH6);
    }];
    
    [self.oneLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.inputView).offset(2 * SCREENH6);
        make.trailing.mas_equalTo(self.inputView).offset(-2 * SCREENH6);
        make.height.mas_equalTo(1 * SCREENH6);
        make.top.mas_equalTo(self.inputView).offset(68 * SCREENH6);
    }];
    
    [self.verifyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.IDCardPictureLabel);
        make.top.mas_equalTo(self.oneLineView.mas_bottom).offset(25 * SCREENH6);
    }];
    
    [self.verifyImageButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.verifyLabel);
        make.width.height.trailing.mas_equalTo(self.contraryImageButton);
    }];
    
    [self.twoLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.leading.trailing.mas_equalTo(1 * SCREENH6);
        make.top.mas_equalTo(self.oneLineView.mas_bottom).offset(68 * SCREENH6);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.twoLineView.mas_bottom).offset(15 * SCREENH6);
        make.leading.mas_equalTo(self.verifyLabel);
    }];
    
    [self.nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.verifyImageButton);
        make.centerY.mas_equalTo(self.nameLabel);
        make.height.mas_equalTo(40 * SCREENH6);
        make.width.mas_equalTo(200 * SCREENH6);
    }];
    
    [self.threeLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.twoLineView.mas_bottom).offset(45 * SCREENH6);
        make.height.leading.trailing.mas_equalTo(self.twoLineView);
    }];
    
    [self.IDNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.nameLabel);
        make.top.mas_equalTo(self.threeLineView.mas_bottom).offset(15 * SCREENH6);
    }];
    
    [self.IDNumberTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.height.mas_equalTo(self.nameTextField);
        make.width.mas_equalTo(250 * SCREENH6);
        make.centerY.mas_equalTo(self.IDNumberLabel);
    }];
    
    [self.fourLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.leading.trailing.mas_equalTo(self.threeLineView);
        make.top.mas_equalTo(self.threeLineView.mas_bottom).offset(45 * SCREENH6);
    }];
    
    [self.workTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.IDNumberLabel);
        make.top.mas_equalTo(self.fourLineView.mas_bottom).offset(15 * SCREENH6);
    }];
    
    [self.oneRightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.IDNumberTextField);
        make.width.mas_equalTo(7.5 * SCREENH6);
        make.height.mas_equalTo(12.5 * SCREENH6);
        make.centerY.mas_equalTo(self.workTypeLabel);
    }];
    [self.workTypeField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.oneRightImageView.mas_leading).offset(-10 * SCREENH6);
        make.centerY.mas_equalTo(self.workTypeLabel);
    }];
    [self.workTypeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.oneRightImageView.mas_leading).offset(-10 * SCREENH6);
        make.centerY.mas_equalTo(self.workTypeLabel);
    }];
    
    [self.fiveLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.height.mas_equalTo(self.fourLineView);
        make.top.mas_equalTo(self.fourLineView.mas_bottom).offset(45 * SCREENH6);
    }];
    
    [self.educationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.workTypeLabel);
        make.top.mas_equalTo(self.fiveLineView.mas_bottom).offset(15 * SCREENH6);
    }];
    
    [self.twoRightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.height.width.mas_equalTo(self.oneRightImageView);
        make.centerY.mas_equalTo(self.educationLabel);
    }];
    [self.educationField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.workTypeButton);
        make.centerY.mas_equalTo(self.educationLabel);
    }];
    [self.educationButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.workTypeButton);
        make.centerY.mas_equalTo(self.educationLabel);
    }];
    
    [self.sixLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.height.mas_equalTo(self.fiveLineView);
        make.top.mas_equalTo(self.fiveLineView.mas_bottom).offset(45 * SCREENH6);
    }];
    
    [self.liveLocalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.educationLabel);
        make.top.mas_equalTo(self.sixLineView.mas_bottom).offset(37 * SCREENH6);
    }];
    [self.liveLocalField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.educationButton);
        make.top.mas_equalTo(self.sixLineView.mas_bottom).offset(15 * SCREENH6);
    }];
    [self.liveLocalButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.educationButton);
        make.top.mas_equalTo(self.sixLineView.mas_bottom).offset(15 * SCREENH6);
    }];
    
    [self.threeRightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.height.width.mas_equalTo(self.twoRightImageView);
        make.centerY.mas_equalTo(self.liveLocalButton);
    }];
    
    [self.sevenLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.sixLineView.mas_bottom).offset(42 * SCREENH6);
        make.trailing.height.mas_equalTo(self.sixLineView);
        make.leading.mas_equalTo(self.inputView).offset(87 * SCREENH6);
    }];
    
    [self.liveLocalTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(self.IDNumberTextField);
        make.trailing.mas_equalTo(self.liveLocalField);
        make.height.mas_equalTo(35 * SCREENH6);
        make.top.mas_equalTo(self.sevenLineView.mas_bottom).offset(3 * SCREENH6);
    }];
    
    [self.eightLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.leading.trailing.mas_equalTo(self.fiveLineView);
        make.top.mas_equalTo(self.sevenLineView.mas_bottom).offset(42 * SCREENH6);
    }];
    
    [self.liveTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.liveLocalLabel);
        make.top.mas_equalTo(self.eightLineView.mas_bottom).offset(15 * SCREENH6);
    }];
    
    [self.fourRightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.height.width.mas_equalTo(self.threeRightImageView);
        make.centerY.mas_equalTo(self.liveTimeLabel);
    }];
    [self.liveTimeField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.liveLocalButton);
        make.centerY.mas_equalTo(self.liveTimeLabel);
    }];
    [self.liveTimeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.liveLocalButton);
        make.centerY.mas_equalTo(self.liveTimeLabel);
    }];
    
    [self.nineLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.height.mas_equalTo(self.eightLineView);
        make.top.mas_equalTo(self.eightLineView.mas_bottom).offset(45 * SCREENH6);
    }];
    
    [self.marrayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.liveTimeLabel);
        make.top.mas_equalTo(self.nineLineView.mas_bottom).offset(15 * SCREENH6);
    }];
    
    [self.fiveRightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.height.width.mas_equalTo(self.fourRightImageView);
        make.centerY.mas_equalTo(self.marrayLabel);
    }];
    [self.marrayField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.marrayLabel);
        make.trailing.mas_equalTo(self.liveTimeButton);
    }];
    
    [self.marrayButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.marrayLabel);
        make.trailing.mas_equalTo(self.liveTimeButton);
    }];
    
    [self.sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.view);
        make.top.mas_equalTo(self.inputView.mas_bottom).offset(10 * SCREENH6);
        make.width.mas_equalTo(300 * SCREENH6);
        make.height.mas_equalTo(42 * SCREENH6);
    }];
}



- (void)didSelectedButton:(UIButton *)button{
    
    if ([self.code isEqualToString:@"1"]) {
        
        [self showHint:@"身份信息验证失败\n请重新提交。"];
        
//        [MBProgressHUD hideHUDForView:self.view animated:YES];
    }else{
       
        switch (button.tag) {
            case 0:
            {
                if(self.typePageModel)
                {
                    [[WSZCustomPickView standViewWithDataArr:self.typePageModel.workTypeEnum Task:^(NSInteger index, id model) {
                        MemberInfoTypeModel * type = model;
                        self.para.workType = @(index);
                        self.workTypeField.text = type.name;
                    }] show];
                }else
                {
                    [self getTypeModel:^{
                        [[WSZCustomPickView standViewWithDataArr:self.typePageModel.workTypeEnum Task:^(NSInteger index, id model) {
                            MemberInfoTypeModel * type = model;
                            self.para.workType = @(index);
                            self.workTypeField.text = type.name;
                        }] show];
                        
                    }];
                }
//                [self check];
            }
                break;
            case 1:
            {
                if(self.typePageModel)
                {
                    [[WSZCustomPickView standViewWithDataArr:self.typePageModel.educationEnum Task:^(NSInteger index, id model) {
                        MemberInfoTypeModel * type = model;
                        self.para.educationType = @(index);
                        self.educationField.text = type.name;
                        
                    }] show];
                }else
                {
                    [self getTypeModel:^{
                        [[WSZCustomPickView standViewWithDataArr:self.typePageModel.educationEnum Task:^(NSInteger index, id model) {
                            MemberInfoTypeModel * type = model;
                            self.para.educationType = @(index);
                            self.educationField.text = type.name;
                            
                        }] show];
                        
                    }];
                }
//                [self check];
            }
                break;
            case 2:
            {
                STPickerArea *pickerArea = [[STPickerArea alloc] init];
                pickerArea.delegate = self;
                pickerArea.contentMode = STPickerContentModeBottom;
                [pickerArea show];
//                [self check];
            }
                break;
            case 3:
            {
                if(self.typePageModel)
                {
                    [[WSZCustomPickView standViewWithDataArr:self.typePageModel.addressSpanEnum Task:^(NSInteger index, id model) {
                        MemberInfoTypeModel * type = model;
                        self.para.liveDuration = @(index);
                        self.liveTimeField.text = type.name;
                        
                    }] show];
//                    [self check];
                }else
                {
                    [self getTypeModel:^{
                        [[WSZCustomPickView standViewWithDataArr:self.typePageModel.addressSpanEnum Task:^(NSInteger index, id model) {
                            MemberInfoTypeModel * type = model;
                            self.para.liveDuration = @(index);
                            self.liveTimeField.text = type.name;
                            
                        }] show];
//                        [self check];
                    }];
                }
//                [self check];
            }
                break;
            default:
            {
                if(self.typePageModel)
                {
                    [[WSZCustomPickView standViewWithDataArr:self.typePageModel.marriageEnum Task:^(NSInteger index, id model) {
                        MemberInfoTypeModel * type = model;
                        self.para.marriageType = @(index);
                        self.marrayField.text = type.name;
                        
                        
                    }] show];
//                    [self check];
                }else
                {
                    [self getTypeModel:^{
                        [[WSZCustomPickView standViewWithDataArr:self.typePageModel.marriageEnum Task:^(NSInteger index, id model) {
                            MemberInfoTypeModel * type = model;
                            self.para.marriageType = @(index);
                            self.marrayField.text = type.name;
                            
//                            [self check];
                        }] show];
//                        [self check];
                    }];
                }
//                [self check];
            }
                break;
        }
//        [self check];
    }
    
}


- (void)check{
    
    if(self.para.idFrontPic.length > 0 && self.para.idBackPic.length > 0 && self.para.faceBodyPic.length > 0 && self.para.workType != nil&& self.para.educationType != nil && self.liveLocalTextField.text.length > 0 && self.liveLocalField.text.length > 0 && self.para.liveDuration != nil && self.para.marriageType != nil)
    {
        [self.sureButton setImage:nil forState:UIControlStateNormal];
        [self.sureButton setTitle:@"保存" forState:UIControlStateNormal];
        [self.sureButton setBackgroundImage:[UIImage imageNamed:@"登录"] forState:UIControlStateNormal];
        [self.sureButton setEnabled: YES];
    }
}

- (void)pickerArea:(STPickerArea *)pickerArea province:(NSString *)province city:(NSString *)city area:(NSString *)area{
    NSString *text = [NSString stringWithFormat:@"%@ %@ %@", province, city, area];
    
    self.liveLocalField.text = text;
    
//    [self check];
}

- (void)didSaveButton{
    
    if(self.para.idFrontPic.length == 0)
    {
        [self showHint:@"请先上传身份证正面"];
        return;
    }
    if(self.para.idBackPic.length == 0)
    {
        [self showHint:@"请先上传身份证反面"];
        return;
    }
    if(self.para.faceBodyPic.length==0)
    {
        [self showHint:@"请先上传真人正面照"];
        return;
    }
    if(self.para.workType == nil)
    {
        [self showHint:@"请选择工作类型"];
        return;
    }
    if(self.para.educationType == nil)
    {
        [self showHint:@"请选择学历"];
        return;
    }
    if(self.liveLocalTextField.text.length == 0)
    {
        [self showHint:@"请选择地区"];
        return;
    }
    if(self.liveLocalField.text.length == 0)
    {
        [self showHint:@"请选择地区"];
        return;
    }
    if(self.para.liveDuration == nil)
    {
        [self showHint:@"请选择居住时长"];
        return;
    }
    if(self.para.marriageType == nil)
    {
        [self showHint:@"请选择婚姻状态"];
        return;
    }
    self.para.name = self.nameTextField.text;
    self.para.idCardNumber = self.IDNumberTextField.text;
    self.para.residenceString = [NSString stringWithFormat:@"%@&%@",[self.liveLocalField.text stringByReplacingOccurrencesOfString:@" " withString:@""],self.liveLocalTextField.text];
    
    [[NetworkTool shareManager] POST:[Interfacefile updatePersonalInfo] Param:[self.para toDictionary] andWaitStr:@"" waitView:self.view success:^(id  _Nullable responseObject) {
        
//        NSLog(@"==%@",responseObject);
        if([[responseObject objectForKey:@"code"]intValue]==0)
        {
//            [self showHint:@"保存成功"];
//            [self.navigationController popViewControllerAnimated:YES];
            DEF_SET_OBJECT(self.nameTextField.text, @"name");
            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@""
                                                                           message:@"保存成功"
                                                                    preferredStyle:UIAlertControllerStyleAlert];
            
            UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel
                                                                  handler:^(UIAlertAction * action) {
                                                                      //响应事件
                                                                      [self.navigationController popViewControllerAnimated:YES];
                                                                  }];
            
            [alert addAction:defaultAction];
            [self presentViewController:alert animated:YES completion:nil];
        }else{
            
            [self showHint:[responseObject objectForKey:@"message"]];
            
            
        }
    } andFailure:^(NSError * _Nonnull error) {
        [self showHint:@"网络错误"];
    }];
    
}




-(void)upLoadImage:(UIImage*)image complete:(void(^)(NSString*imageUrl))complete
{
    
    [[NetworkTool shareManager] POST:[Interfacefile uploader] Param:@{} File:UIImageJPEGRepresentation(image, 0.8) fileKey:@"fileList" andFileName:@"fileName.jpg" andWaitStr:@"" waitView:nil success:^(id  _Nullable responseObject) {
        if([[responseObject objectForKey:@"code"]intValue]==0)
        {
            
            if([[responseObject objectForKey:@"data"] isKindOfClass:[NSArray class]]&&[[responseObject objectForKey:@"data"] count])
            complete([[responseObject objectForKey:@"data"] firstObject]);
        }else{
            [self showHint:[responseObject objectForKey:@"message"]];
            
            
        }
    } andFailure:^(NSError * _Nonnull error) {
        [self showHint:@"网络错误"];
        
    }];
}











- (UILabel *)setupLabelWith:(NSString *)string{
    
    UILabel * label = [UILabel new];
    
    label.font = [UIFont systemFontOfSize:14.5 * SCREENH6];
    label.textColor = ColorWithRGB(0x303c41);
    label.text = string;
    
    return label;
}


- (UIButton *)setupButtonUIImageView{
    
    UIButton * imageView = [UIButton new];
    [imageView setBackgroundImage:[UIImage imageNamed:@"识别框"] forState:UIControlStateNormal];
    imageView.clipsToBounds = YES;
    return imageView;
}


- (UIView *)setupLineView{
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0xdbdbdb);
    
    return lineView;
}


- (UIButton *)setupTitleButtonWith:(NSString *)string{
    
    UIButton * button = [UIButton new];
    
    [button setTitleColor:ColorWithRGB(0xcecece) forState:UIControlStateNormal];
    [button addTarget:self action:@selector(didSelectedButton:) forControlEvents:UIControlEventTouchUpInside];
    button.titleLabel.font = [UIFont systemFontOfSize:14.5 * SCREENH6];
    
    
    return button;
}

- (UITextField *)setupTextField:(NSString *)title{
    
    UITextField * textField = [[UITextField alloc] init];
    
    textField.borderStyle = UITextBorderStyleNone;
    textField.backgroundColor = [UIColor clearColor];
    textField.layer.borderColor = [[UIColor clearColor] CGColor];
    textField.textAlignment = NSTextAlignmentRight;
    //设置光标颜色
    textField.tintColor = ColorWithRGB(0xcecece);
    //修改占位符文字颜色
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = ColorWithRGB(0xcecece);
//    attrs[NSFontAttributeName] = [UIFont fontWithName:@"PingFangSC-Regular" size:14 * SCREENH6];
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:14 * SCREENH6];
    //修改占位符文字颜色
    textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:title attributes:attrs];
    textField.textColor = ColorWithRGB(0x303c41);
    textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 22 * SCREENH6, 0)];
    //设置显示模式为永远显示(默认不显示)
    textField.leftViewMode = UITextFieldViewModeAlways;
//    textField.font = [UIFont fontWithName:@"PingFangSC-Regular" size:14.5 * SCREENH6];
    textField.font = [UIFont systemFontOfSize:14 * SCREENH6];
    
    return textField;
}


- (UIImageView *)setupRightImage{
    
    UIImageView * imageView = [UIImageView new];
    
    imageView.image = [UIImage imageNamed:@"返回-拷贝-6"];
    
    return imageView;
}


- (void)backToLastView{
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)getPageModel
{
    
    if (self.currentStep > 1) {    
        ParaModel*para = [ParaModel new];
        
        
        [[NetworkTool shareManager] POST:[Interfacefile loadCurrentPersonalInfo] Param:[para toDictionary] andWaitStr:@"" waitView:self.view success:^(id  _Nullable responseObject) {
            if([[responseObject objectForKey:@"code"]intValue]==0)
            {
                self.pageModel = [[MemberInfoModel alloc] initWithDictionary:[responseObject objectForKey:@"data"] error:nil];
                self.para.idFrontPic = self.pageModel.idFront;
                self.para.idBackPic = self.pageModel.idBack;
                self.para.faceBodyPic = self.pageModel.idBody;
                self.para.name = self.pageModel.name;
                self.para.idCardNumber = self.pageModel.idNumber;
                self.para.workType = self.pageModel.workType;
                self.para.educationType = self.pageModel.education;
                self.para.residenceString = self.pageModel.addressCurrent;
                self.para.liveDuration = self.pageModel.addressSpan;
                self.para.marriageType = self.pageModel.marriage;
                [self getTypeModel:nil];
                
            }else{
                
                [self showHint:[responseObject objectForKey:@"message"]];
                
                
            }
        } andFailure:^(NSError * _Nonnull error) {
            [self showHint:@"网络错误"];
        }];
    }
    
    
}

-(void)getTypeModel:(void(^)())complete
{
    ParaModel*para = [ParaModel new];
    
    
    [[NetworkTool manager] POST:[Interfacefile loadUserRelatedEnums] Param:[para toDictionary] andWaitStr:@"" waitView:nil success:^(id  _Nullable responseObject) {
        if([[responseObject objectForKey:@"code"]intValue]==0)
        {
            self.typePageModel = [[MemberInfoTypePageModel alloc] initWithDictionary:[responseObject objectForKey:@"data"] error:nil];
            if(complete)
            {
                complete();
            }else
            {
                [self updateView];
            }
        }else{
            if(complete)
            [self showHint:[responseObject objectForKey:@"message"]];
            
            
        }
    } andFailure:^(NSError * _Nonnull error) {
        if(complete)
        [self showHint:@"网络错误"];
    }];
    
}


-(void)getMemberName:(UIImage*)image
{
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    [self.frontImageButton setImage:image forState:UIControlStateNormal];
    
    [[NetworkTool shareManager] POST:[Interfacefile scanIdFrontGetIdNumber] Param:@{} File:UIImageJPEGRepresentation(image, 1) fileKey:@"file" andFileName:@"fileName.jpg" andWaitStr:@"" waitView:nil success:^(id  _Nullable responseObject) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        if([[responseObject objectForKey:@"code"] intValue]==0)
        {
           
            
            [self upLoadImage:image complete:^(NSString *imageUrl) {
                self.para.idFrontPic = imageUrl;
                
                self.nameTextField.text = [[responseObject objectForKey:@"data"] objectForKey:@"name"];
                self.IDNumberTextField.text = [[responseObject objectForKey:@"data"] objectForKey:@"idCardNum"];
                
            }];
           
        }else{
//                [self showHint:[responseObject objectForKey:@"message"]];
            UIAlertController* alert = [UIAlertController alertControllerWithTitle:@""
                                                                           message:[responseObject objectForKey:@"message"]
                                                                    preferredStyle:UIAlertControllerStyleAlert];
            
            UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel
                                                                  handler:^(UIAlertAction * action) {
                                                                      //响应事件
                                                                     [self.frontImageButton setImage:nil forState:UIControlStateNormal];
                                                                  }];
            
            [alert addAction:defaultAction];
            [self presentViewController:alert animated:YES completion:nil];
            
        }
    } andFailure:^(NSError * _Nonnull error) {
        [self showHint:@"网络错误"];

    }];
    
}



-(void)verifyMember:(UIImage*)image
{
    if(self.nameTextField.text.length == 0)
    {
        [self showHint:@"请先上传验证身份证"];
        return;
    }
    
    
    ParaModel*para = [ParaModel new];
    para.name = self.nameTextField.text;
    para.idCardNo = self.IDNumberTextField.text;
    
    [[NetworkTool shareManager] POST:[Interfacefile facePicCheck] Param:[para toDictionary] File:UIImageJPEGRepresentation(image, 0.8) fileKey:@"file" andFileName:@"filename.jpg" andWaitStr:@"" waitView:self.view success:^(id  _Nullable responseObject) {
        if([[responseObject objectForKey:@"code"]intValue]==0)
        {
            
            self.code = @"0";
            
           [self upLoadImage:image complete:^(NSString *imageUrl) {
               
               [self.verifyImageButton setImage:image forState:UIControlStateNormal];
               self.para.faceBodyPic = imageUrl;
           }];

        }else{
            [self showHint:[responseObject objectForKey:@"message"]];
            
            
        }
    } andFailure:^(NSError * _Nonnull error) {
        [self showHint:@"网络错误"];
    }];
    
}






-(void)updateView
{
    
    
    [self.frontImageButton sd_setImageWithURL:[NSURL URLWithString:self.pageModel.idFront] forState:UIControlStateNormal];
    [self.contraryImageButton sd_setImageWithURL:[NSURL URLWithString:self.pageModel.idBack]  forState:UIControlStateNormal];
    [self.verifyImageButton sd_setImageWithURL:[NSURL URLWithString:self.pageModel.idBody]  forState:UIControlStateNormal];
    self.nameTextField.text = self.pageModel.name;
    self.IDNumberTextField.text = self.pageModel.idNumber;
    [self.typePageModel.workTypeEnum enumerateObjectsUsingBlock:^(MemberInfoTypeModel*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if(self.pageModel.workType&& ([obj.value integerValue]==[self.pageModel.workType intValue]))
        {
            self.workTypeField.text = obj.name;
//            [self check];
        }
    }];
    [self.typePageModel.educationEnum enumerateObjectsUsingBlock:^(MemberInfoTypeModel*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if(self.pageModel.education&& ([obj.value integerValue]==[self.pageModel.education intValue]))
        {
            self.educationField.text = obj.name;
//            [self check];
        }
    }];
    [self.typePageModel.addressSpanEnum enumerateObjectsUsingBlock:^(MemberInfoTypeModel*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if(self.pageModel.addressSpan&& ([obj.value integerValue]==[self.pageModel.addressSpan intValue]))
        {
            self.liveTimeField.text = obj.name;
//            [self check];
        }
    }];
    [self.typePageModel.marriageEnum enumerateObjectsUsingBlock:^(MemberInfoTypeModel*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if(self.pageModel.marriage&& ([obj.value integerValue]==[self.pageModel.marriage intValue]))
        {
            self.marrayField.text = obj.name;
//            [self check];
        }
    }];
    
    NSArray *array = [self.pageModel.addressCurrent componentsSeparatedByString:@"&"];
    
    self.liveLocalField.text = array.firstObject;
    self.liveLocalTextField.text = array.lastObject;
//    [self check];
}

#pragma mark delegate
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.nameTextField resignFirstResponder];
    [self.IDNumberTextField resignFirstResponder];
    [self.liveLocalTextField resignFirstResponder];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [self.nameTextField resignFirstResponder];
    [self.IDNumberTextField resignFirstResponder];
    [self.liveLocalTextField resignFirstResponder];
    return YES;
}
-(ParaModel*)para
{
    if(!_para)
    {
        _para = [ParaModel new];
    }
    return _para;
}



@end
